package cn.com.zpark.listener.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @PackageName: cn.com.zpark.listener.servlet
 * @ClassName: ServletDemo02
 * @Description:
 * @author: RZS
 * @date: 2021/11/22  15:29
 */
@WebServlet("/sd2.do")
public class ServletDemo02 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取session
        HttpSession session = request.getSession();
        // 绑定数据
        session.setAttribute("user", "user");
        // 替换绑定数据的值
        session.setAttribute("user", "dac");
        // 删除绑定数据
        session.removeAttribute("user");
    }
}
